package longrise.phone.com.bjjt_jyb.compensate;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.longrise.android.FormParameter;
import com.longrise.android.FrameworkManager;
import com.longrise.android.LFView;

import longrise.phone.com.bjjt_jyb.R;

/**
 * 生成协议书温馨提示，提示挪车，Created by Administrator on 2016/5/12.
 */

public class PromptAfterCreateAppointView extends LFView implements View.OnClickListener{
    private Context context = null;
    private View view = null;
    private Button bt_promptaftercreateappoint_ensure;
    private String appCaseno;
    private LinearLayout hn_btn_back;
    private String isSingleCar;//0是单车

    public PromptAfterCreateAppointView(Context c, String appcaseno) {
        super(c);
        this.context = c;
        this.appCaseno = appcaseno;
    }
    public void setIsSingleCar(String  isSingleCar) {
        this.isSingleCar = isSingleCar;
    }
    @Override
    public void refreshByTime() {

    }

    @Override
    public FormParameter getFormParameter() {
        FormParameter fp = new FormParameter();
        fp.setShowtitle(false);
        return fp;
    }

    @Override
    public void refresh() {

    }

    @Override
    public View getView() {
        return view;
    }

    @Override
    public void init() {
        initView();
        regEvent(true);
    }

    private void initView() {
        view = View.inflate(context, R.layout.view_promptaftercreateappoint, null);
        bt_promptaftercreateappoint_ensure = (Button) view.findViewById(R.id.bt_promptaftercreateappoint_ensure);
        hn_btn_back = (LinearLayout) view.findViewById(R.id.hn_btn_back);
        hn_btn_back.setVisibility(View.INVISIBLE);
        TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
        tv_title.setText("温馨提示");
    }
    private void regEvent(boolean b) {
        if (null != bt_promptaftercreateappoint_ensure) {
            bt_promptaftercreateappoint_ensure.setOnClickListener(b ? this : null);
        }
        if (null != hn_btn_back) {
            hn_btn_back.setOnClickListener(b ? this : null);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_promptaftercreateappoint_ensure:
                if(null!=isSingleCar&&isSingleCar.equals("0")){//单车事故
                    AccidentLoadingView singleaccidentloadingview = new AccidentLoadingView(context, appCaseno);
                    FrameworkManager.getInstance().showNewForm(context, singleaccidentloadingview);
                }else {
                    SelectAccidentView selectaccidentview = new SelectAccidentView(context, appCaseno,Integer.valueOf(isSingleCar));
                    FrameworkManager.getInstance().showNewForm(context, selectaccidentview);
                }
                break;
            case R.id.hn_btn_back:
                closeForm();
                OnDestroy();
                break;

        }
    }
}
